package com.tianpengtech.admin.fairbankno;
import com.jfinal.aop.Before;
import com.jfinal.plugin.activerecord.Model;
import com.tianpengtech.admin.AbstractAdminController;
import com.tianpengtech.admin.InitInterceptor;
import com.tianpengtech.common.exception.ValidateException;
import com.tianpengtech.common.model.fair.Fair;
import com.tianpengtech.common.model.fairbankno.FairBankNo;
import com.tianpengtech.common.model.fairwithdraw.FairWithdraw;

/**
* 路由配置地址：add("/admin/fairbankno", FairBankNoAdminController.class, "/admin/fairbankno");
* 数据库映射地址：arp.addMapping(FairBankNo.dao.tableName(),FairBankNo.class);
*/
@Before(InitInterceptor.class)
public class FairBankNoAdminController extends AbstractAdminController{

	@Override
	protected void config() {
		this.clazz=FairBankNo.class;
		this.service=new FairBankNoAdminServiceImpl();
	}

	@Override
	public void beforeAdd() {

	}

	@Override
	public void beforeAdd(Model< ? > model) throws ValidateException {

	}

	@Override
	public void beforeQueryById(Model<?> model, int id) {

		FairBankNo bankNo = FairBankNo.dao.findById(id);
		long wh_id = bankNo.getLong(FairBankNo.WH_ID);
		setAttr("fair", Fair.dao.findById(wh_id));
	}

	@Override
	public void beforeUpdate(Model< ? > model) throws ValidateException {

	}

	@Override
	public void beforeDelete(Model< ? > model) {

	}

	@Override
	public void parsePageRecord(Object results) {
		FairBankNo bankNo = (FairBankNo)results;
		Fair fair= Fair.dao.findById(bankNo.getInt(FairBankNo.WH_ID));
		if(fair!=null){
			bankNo.set(FairBankNo.WH_ID, fair.getStr(Fair.NICK_NAME));
		}
	}
}

	